package bishi.aishu;

import java.util.Scanner;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2021/10/12 17:33
 */
public class one {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int _n;
        _n = Integer.parseInt(in.nextLine().trim());
        System.out.println(new one().findNdigit(_n));
        System.out.println(new one().findNdigit2(_n));
    }

    public int findNdigit(int n) {
        int i = 9;
        int len = 1;
        while (n - i * len > 0) {
            n -= (i * len);
            len++;
            i*= 10;
        }
        int p = n;
        int next = p/len;
        p%=len;
        if (p==0) next--;
        int now = 1;
        int q = len;
        while (q>1){
            now*=10;
            q--;
        }
        return (""+(now+next)).charAt((p+len-1)%len)-'0';
    }

    public int findNdigit2(int n) {
        StringBuffer sb = new StringBuffer();
        for (int i = 1; i <= n; i++) {
            sb.append(i);
        }
        return sb.toString().charAt(n - 1) - '0';
    }

    public int findNdigit3(int n) {
        int p = n;
        int len = 0;
        int i=1;
        for(;i<=n;i++){
            len = (""+i).length();
            p -= len;
            if(p<=0) break;
        }
        return (""+i).charAt(p+len-1)-'0';
    }

}
//101112